export class Conversation {
    constructor(title = 'New Conversation') {
        this.id = crypto.randomUUID();
        this.title = title;
        this.messages = [];
        this.createdAt = new Date();
    }

    addMessage(message) {
        this.messages.push(message);
    }

    getMessages() {
        return [...this.messages];
    }

    toJSON() {
        return {
            id: this.id,
            title: this.title,
            messages: this.messages.map(msg => msg.toJSON()),
            createdAt: this.createdAt
        };
    }
}